package com.JingYan.Thread;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * spring 的线程
 *
 * @author Dong_Jia_Qi on 2022/6/8
 */
@Slf4j
@Component
public class SpringAsync {
    @Async
    public void testScheduleTask(){
        log.info("spring线程执行任务");
        int i = 0;
        try {
            while(true){
                log.info("spring线程执行"+ ++i);
                Thread.sleep(1000);
            }

        } catch (InterruptedException e) {
            // log.error("暂停异常",e);
        }
        log.info("spring线程执行结束");
    }
}
